// This source is subject to the Microsoft Public License.
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
// All other rights reserved.

using System;
using System.Drawing;
using System.Collections;
using System.Configuration;
using System.ComponentModel;
using System.IO;
using System.Windows.Forms;
using System.Xml;

namespace QuoteAdvantageEditor
{
	/// <summary>
	/// Summary description for SettingsDlg.
	/// </summary>
	public class SettingsDlg : System.Windows.Forms.Form
	{
      private Settings objSettings = null;
      private System.Windows.Forms.Button btnOK;
      private System.Windows.Forms.Button btnCancel;
      private System.Windows.Forms.Label label3;
      private System.Windows.Forms.TextBox txtWebServiceUrl;
      private System.Windows.Forms.Label label1;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
      
      public Settings SettingsData
      {
         get { return objSettings; }
         set { objSettings = value; }
      }

		public SettingsDlg()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

     

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
         this.btnOK = new System.Windows.Forms.Button();
         this.btnCancel = new System.Windows.Forms.Button();
         this.label3 = new System.Windows.Forms.Label();
         this.txtWebServiceUrl = new System.Windows.Forms.TextBox();
         this.label1 = new System.Windows.Forms.Label();
         this.SuspendLayout();
         // 
         // btnOK
         // 
         this.btnOK.Location = new System.Drawing.Point(232, 80);
         this.btnOK.Name = "btnOK";
         this.btnOK.Size = new System.Drawing.Size(88, 23);
         this.btnOK.TabIndex = 3;
         this.btnOK.Text = "OK";
         this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
         // 
         // btnCancel
         // 
         this.btnCancel.Location = new System.Drawing.Point(328, 80);
         this.btnCancel.Name = "btnCancel";
         this.btnCancel.Size = new System.Drawing.Size(88, 23);
         this.btnCancel.TabIndex = 4;
         this.btnCancel.Text = "Cancel";
         this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
         // 
         // label3
         // 
         this.label3.Location = new System.Drawing.Point(8, 16);
         this.label3.Name = "label3";
         this.label3.Size = new System.Drawing.Size(176, 16);
         this.label3.TabIndex = 6;
         this.label3.Text = "Microsoft CRM Server URL:";
         this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
         // 
         // txtWebServiceUrl
         // 
         this.txtWebServiceUrl.Location = new System.Drawing.Point(184, 16);
         this.txtWebServiceUrl.Name = "txtWebServiceUrl";
         this.txtWebServiceUrl.Size = new System.Drawing.Size(232, 21);
         this.txtWebServiceUrl.TabIndex = 8;
         this.txtWebServiceUrl.Text = "http://vm2003srv/MSCRMServices";
         // 
         // label1
         // 
         this.label1.Location = new System.Drawing.Point(136, 48);
         this.label1.Name = "label1";
         this.label1.Size = new System.Drawing.Size(280, 16);
         this.label1.TabIndex = 9;
         this.label1.Text = "(typical location will be: http://my_server_name:5555)";
         // 
         // SettingsDlg
         // 
         this.AcceptButton = this.btnOK;
         this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
         this.ClientSize = new System.Drawing.Size(426, 120);
         this.Controls.Add(this.label1);
         this.Controls.Add(this.txtWebServiceUrl);
         this.Controls.Add(this.label3);
         this.Controls.Add(this.btnCancel);
         this.Controls.Add(this.btnOK);
         this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
         this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
         this.MaximizeBox = false;
         this.MinimizeBox = false;
         this.Name = "SettingsDlg";
         this.ShowInTaskbar = false;
         this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
         this.Text = "Settings";
         this.Load += new System.EventHandler(this.SettingsDlg_Load);
         this.ResumeLayout(false);

      }
		#endregion

      private void SettingsDlg_Load(object sender, System.EventArgs e)
      {
         Cursor oldCursor = Cursor.Current;
         Cursor.Current = Cursors.WaitCursor; 
         txtWebServiceUrl.Text = objSettings.strWebServerUrl;
         Cursor.Current = oldCursor;
      }

      private void btnOK_Click(object sender, System.EventArgs e)
      {
         Cursor oldCursor = Cursor.Current;
         Cursor.Current = Cursors.WaitCursor; 
         objSettings.strWebServerUrl = txtWebServiceUrl.Text;
         objSettings.SaveSettings();

         this.DialogResult = DialogResult.OK;
         this.Close();
         Cursor.Current = oldCursor;
      }
      
      private void btnCancel_Click(object sender, System.EventArgs e)
      {
         this.Close();
      }

	} // end class
}
